package com.myCinema.biz.servlet;

import java.io.IOException;
import java.sql.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.myCinema.dao.HibernateUtil;
import com.myCinema.dao.impl.CategoryDaoImpl;
import com.myCinema.dao.impl.MovieDaoImpl;
import com.myCinema.entity.Category;
import com.myCinema.entity.Movie;

public class EditMovieServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		List<Category> list = new CategoryDaoImpl().getAll();
		int id = 0;
		if(request.getParameter("id")!=null && !request.getParameter("id").isEmpty())
			id = Integer.parseInt(request.getParameter("id")); 
		Movie movie = (Movie)new MovieDaoImpl().getMovieById(id);
		request.setAttribute("clist", list);
		request.setAttribute("movie", movie);
		
		request.getRequestDispatcher("editMovies.jsp").forward(request, response);
	}
	

}
